package com.corpgovernment.job.batchimport.entity.db;

import com.corpgovernment.common.base.BaseUserInfo;
import com.corpgovernment.common.holder.TraceIdHolder;
import com.corpgovernment.job.batchimport.enums.BatchImportStatusEnum;
import com.ctrip.corp.obt.generic.core.context.TraceContext;
import lombok.AllArgsConstructor;
import lombok.Builder;
import lombok.Data;
import lombok.NoArgsConstructor;

import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import java.util.Date;

/**
 * @author ldma
 * @date 2024/1/9
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
@Builder
@Table(name = "mb_batch_import_record")
public class BatchImportRecordDo {

    @Id
    @GeneratedValue(generator = "JDBC")
    private Long id;
    private String type;
    private String orgId;
    private String uid;
    private String fileName;
    private String errorFileUrl;
    private Integer lineCount;
    private Integer successCount;
    private Integer errorCount;
    private String requestId;
    private String status;
    private Boolean deleted;
    private Date createTime;

    public BatchImportRecordDo(String type, String fileName, BaseUserInfo baseUserInfo) {
        this.type = type;
        this.fileName = fileName;
        this.orgId = baseUserInfo.getOrgId();
        this.uid = baseUserInfo.getUid();
        this.requestId = TraceContext.getRequestId();
    }

}
